@extends('layout.adminlayout')
@section('css')
<script src="/admin/js/metisMenu.min.js"></script>
<script src="/admin/js/custom.js"></script>
<link href="/admin/css/custom.css" rel="stylesheet">
<link href="/admin/css/add_manage.css" rel="stylesheet">
@endsection
@section('content')
<div class="forms">
	<div class=" form-grids row form-grids-right">
		<div class="widget-shadow " data-example-id="basic-forms"> 
			<div class="form-title">
				<h4>客户编辑 :</h4>
			</div>
			<div class="form-body">
				<form action="/admin/area/create" method="post" class="form-horizontal">
					{{csrf_field()}}
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-2 control-label">
							用户名称 :
						</label>
						<div class="col-sm-9">
							<input type="hidden" name="uid" id="uid" value="{{$data['uid']}}">
							<input type="text" class="form-control" name="username" placeholder="用户名" id="username" value="{{$data['username']}}">
						</div>
					</div>
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-2 control-label">
							手机号 :
						</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" name="mobile" placeholder="手机号" id="mobile" value="{{$data['mobile']}}">
						</div>
					</div>
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-2 control-label">
							固定电话 :
						</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" name="telephone" placeholder="固定电话" id="telephone" value="{{$data['telephone']}}">
						</div>
					</div>
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-2 control-label">
							邮箱 :
						</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" name="email" placeholder="邮箱" id="email" value="{{$data['email']}}">
						</div>
					</div>
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-2 control-label">
							微信号 :
						</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" name="weixin" placeholder="微信号" id="weixin" value="{{$data['weChat']}}">
						</div>
					</div>
					<div class="col-sm-offset-2">
						<button type="button" class="btn btn-default" id="sub" style="margin-left: 0.38rem">提交</button>
					</div>
				</form> 
			</div>
		</div>
	</div>
</div>
<script>
    //提交表单
	$('#sub').click(function () {
	    var username = $('#username').val();
	    var mobile = $('#mobile').val();
	    var telephone = $('#telephone').val();
	    var email = $('#email').val();
	    var weixin = $('#weixin').val();
	    var uid = $('#uid').val();
		if(username !='' && mobile !=''){
            $.ajax({
                type:'post',
                url:'/admin/user/edit',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
					'uid':uid,
                    'username':username,
                    'mobile':mobile,
                    'telephone':telephone,
					'email':email,
					'weixin':weixin
                },
                dataType:'json',
                success:function (data) {
					if(data.status == '1'){
                        location.href  = '/admin/user/index';
					}else{
					    return false;
					}
                }
            })
		}else{
		    alert('请填写全部信息再提交')
            return false;
		}
    });
</script>
<script src="/admin/js/add_manage.js"></script>
@endsection